<include file="public@header"/>
<style type="text/css">

.item {
float: left;
clear: both;
margin-bottom: 5px;
}
/* 向上的箭头 */

.arrow-top {
font-size: 0;
line-height: 0;
border-width: 5px;
border-color: #18BC9C;
border-top-width: 0;
border-style: dashed;
border-bottom-style: solid;
border-left-color: transparent;
border-right-color: transparent;
}

/* 向下的箭头 */

.arrow-bottom {
font-size: 0;
line-height: 0;
border-width: 5px;
border-color: #18BC9C;
border-bottom-width: 0;
border-style: dashed;
border-top-style: solid;
border-left-color: transparent;
border-right-color: transparent;
}


.fl{
    float: left;
}
.fr{
    float: right;
}
.clear{
    clear: both;
}
</style>
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a>{:lang('USER_INDEXADMIN_INDEX')}</a></li>
        <li><a href="{:url('adminIndex/add')}">添加主播</a></li>
    </ul>
    <form name="search" class="well form-inline margin-top-20" method="post" action="{:url('user/adminIndex/index')}">
        性别：
            <select class="form-control" name="sex" style="width: 100px;">
                <option value=''>不限</option>
                <option value="1" <if condition="input('request.sex') neq '' && input('request.sex') eq 1">selected</if>>男</option>
                <option value="2" <if condition="input('request.sex') neq '' && input('request.sex') eq 2">selected</if>>女</option>
                
            </select>
        注册时间：
            <input class="form-control js-bootstrap-date" name="start_time" id="start_time" value="{:input('request.start_time')}" aria-invalid="false" style="width: 110px;"> - 
            <input class="form-control js-bootstrap-date" name="end_time" id="end_time" value="{:input('request.end_time')}" aria-invalid="false" style="width: 110px;">
        用户ID：
        <input class="form-control" type="text" name="uid" style="width: 200px;" value="{:input('request.uid')}"
               placeholder="请输入用户ID">
        关键字：
        <input class="form-control" type="text" name="keyword" style="width: 200px;" value="{:input('request.keyword')}"
               placeholder="用户名/昵称/手机">
        <input class="form-control" type="hidden" name="coin_status" value="{:input('request.coin_status')}" >
        <input class="form-control" type="hidden" name="consumption_status" value="{:input('request.consumption_status')}" >
        <input class="form-control" type="hidden" name="votes_status" value="{:input('request.votes_status')}" >
        <input class="form-control" type="hidden" name="votestotal_status" value="{:input('request.votestotal_status')}" >
        <input class="form-control" type="hidden" name="createtime_status" value="{:input('request.createtime_status')}" >

        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('user/adminIndex/index')}">清空</a>
		<br>
		<br>
		用户数：{$nums}  (根据条件统计)
    </form>
    <form method="post" class="js-ajax-form">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th>ID</th>
                <th>{:lang('USERNAME')}</th>
                <th>{:lang('NICENAME')}</th>
                <th>{:lang('AVATAR')}</th>
                <th>性别</th>
                <th class="coin_top">
                    <p class="fl">{$configpub['name_coin']}</p>
                    <p class="fr">
                        <if condition="$coin_status neq '1'"><span class="item arrow-top" title="从低到高排序"></span></if>
                        <if condition="$coin_status neq '-1'"><span class="item arrow-bottom" title="从高到底排序"></span></if>
                    </p>
                    <p class="clear"></p>
                    
                </th>
                <th class="consumption_top">
                    <p class="fl">总消费</p>
                    <p class="fr">
                        <if condition="$consumption_status neq '1'"><span class="item arrow-top" title="从低到高排序"></span></if>
                        <if condition="$consumption_status neq '-1'"><span class="item arrow-bottom" title="从高到底排序"></span></if>
                    </p>
                    <p class="clear"></p>
                </th>
                <th class="votes_top">
                    <p class="fl">{$configpub['name_votes']}</p>
                    <p class="fr">
                        <if condition="$votes_status neq '1'"><span class="item arrow-top" title="从低到高排序"></span></if>
                        <if condition="$votes_status neq '-1'"><span class="item arrow-bottom" title="从高到底排序"></span></if>
                    </p>
                    <p class="clear"></p>
                </th>
                <th class="votestotal_top">
                    <p class="fl">总收益</p>
                    <p class="fr">
                        <if condition="$votestotal_status neq '1'"><span class="item arrow-top" title="从低到高排序"></span></if>
                        <if condition="$votestotal_status neq '-1'"><span class="item arrow-bottom" title="从高到底排序"></span></if>
                    </p>
                    <p class="clear"></p>
                </th>
                <th>手机</th>
                <th>推荐值</th>
                <th>实名认证</th>
                <th>主播认证</th>
                <th class="createtime_top">
                    <p class="fl">{:lang('REGISTRATION_TIME')}</p>
                    <p class="fr">
                        <if condition="$createtime_status neq '1'"><span class="item arrow-top" title="正序排序"></span></if>
                        <if condition="$createtime_status neq '-1'"><span class="item arrow-bottom" title="倒序排序"></span></if>
                    </p>
                    <p class="clear"></p>
                </th>
                <th>{:lang('LAST_LOGIN_TIME')}</th>
                <th>{:lang('LAST_LOGIN_IP')}</th>
                <th>{:lang('STATUS')}</th>
                <th>{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>
            <php>
                $user_statuses=array("0"=>lang('USER_STATUS_BLOCKED'),"1"=>lang('USER_STATUS_ACTIVATED'),"2"=>lang('USER_STATUS_UNVERIFIED'),"3"=>'已注销');
                $user_auth=array('0'=>'×','1'=>'√');
                $author_auth=array('0'=>'×','1'=>'√');
            </php>
            <foreach name="list" item="vo">
                <tr>
                    <td>{$vo.id}</td>
                    <td>{$vo['user_login']?$vo['user_login']:($vo['mobile']?$vo['mobile']:lang('THIRD_PARTY_USER'))}
                    </td>
                    <td>{$vo['user_nickname']?$vo['user_nickname']:lang('NOT_FILLED')}</td>
                    <td><img width="25" height="25" src="{:get_upload_path($vo['avatar'])}"/></td>
                    <td><if condition="$vo['sex'] eq 1">男<elseif condition="$vo['sex'] eq '2'"/>女<else />未设置</if></td>
                    <td>{$vo.coin}</td>
                    <td>{$vo.consumption}</td>
                    <td>{$vo.votes}</td>
                    <td>{$vo.votestotal}</td>
                    <td>{$vo.mobile}</td>
                    <td>{$vo.recommend_val}</td>
                    <td>{$user_auth[$vo.isauth]}</td>
                    <td>{$author_auth[$vo.isauthor_auth]}</td>
                    <td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
                    <td><if condition="$vo['last_login_time'] gt 0">{:date('Y-m-d H:i:s',$vo['last_login_time'])}</if></td>
                    <td>{$vo.last_login_ip}</td>
                    <td>
                        <switch name="vo.user_status">
                            <case value="0">
                                <span class="label label-danger">{$user_statuses[$vo['user_status']]}</span>
                            </case>
                            <case value="1">
                                <span class="label label-success">{$user_statuses[$vo['user_status']]}</span>
                            </case>
                            <case value="2">
                                <span class="label label-warning">{$user_statuses[$vo['user_status']]}</span>
                            </case>
							<case value="3">
                                <span class="label label-warning">{$user_statuses[$vo['user_status']]}</span>
                            </case>
                        </switch>
                    </td>
                    <td>
					
						<if condition="$vo.user_status neq '3'">

							<if condition="$vo.isauth">
							    
							    <a class="btn btn-xs btn-danger js-ajax-dialog-btn"
								   href="{:url('adminIndex/cancelUserAuth',array('id'=>$vo['id']))}"
								   data-msg="确定要取消实名认证吗？<br />取消后主播认证也将被取消。">取消实名认证
                                </a>
							</if>

                            <if condition="$vo.isauthor_auth">
                                <a class="btn btn-xs btn-info  setrecommend" data-uid="{$vo.id}" data-value="{$vo.recommend_val}">推荐值</a>
                                <a class="btn btn-xs btn-danger js-ajax-dialog-btn"
                                   href="{:url('adminIndex/cancelAuthorAuth',array('id'=>$vo['id']))}"
                                   data-msg="确定要取消主播认证吗？">取消主播认证
                                </a>
                            </if>

							<empty name="vo.user_status">
								<a class="btn btn-xs btn-success js-ajax-dialog-btn"
								   href="{:url('adminIndex/cancelban',array('id'=>$vo['id']))}"
								   data-msg="{:lang('ACTIVATE_USER_CONFIRM_MESSAGE')}">{:lang('ACTIVATE_USER')}</a>
						<else/>
								<a class="btn btn-xs btn-warning js-ajax-dialog-btn"
								   href="{:url('adminIndex/ban',array('id'=>$vo['id']))}"
								   data-msg="{:lang('BLOCK_USER_CONFIRM_MESSAGE')}">{:lang('BLOCK_USER')}</a>
							</empty>
						</if>
                        <a class="btn btn-xs btn-primary" href='{:url("adminIndex/edit",array("id"=>$vo["id"]))}'>{:lang('EDIT')}</a>
                        <a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('adminIndex/del',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
    <script>
        $(function(){

            Wind.use('layer');
            $('.setrecommend').click(function(){
                var _this=$(this);
                var uid=_this.data('uid');
                var recommend=_this.data('value');

                layer.prompt({
                    formType: 0,
                    title: '推荐值',
                    value: recommend,
                }, function(value, index, elem){
                    $.ajax({
                        url:'{:url('user/adminIndex/setrecommend')}',
                        type:'POST',
                        data:{uid:uid,recommend:value},
                        dataType:'json',
                        success:function(data){
                            var code=data.code;
                            if(code==0){
                                layer.msg(data.msg);
                                return !1;
                            }
                            layer.msg(data.msg,{},function(){
                                layer.closeAll();
                                location.reload();
                            });
                            
                        },
                        error:function(){
                            layer.msg('操作失败，请重试')
                        }
                    });
                    
                });
                
            });

            //钻石由低到高排序
            $(".coin_top .arrow-top").on('click',function(){
                //layer.msg("钻石向上");
                change_status('coin','1');
            });
            //钻石由高到低排序
            $(".coin_top .arrow-bottom").on('click',function(){
                //layer.msg("钻石向下");
                change_status('coin','-1');
            });

            //总消费由低到高排序
            $(".consumption_top .arrow-top").on('click',function(){
                //layer.msg("总消费向上");
                change_status('consumption','1');
            });

            //总消费由高到低排序
            $(".consumption_top .arrow-bottom").on('click',function(){
                //layer.msg("总消费向下");
                change_status('consumption','-1');
            });

            //映票由低到高排序
            $(".votes_top .arrow-top").on('click',function(){
                //layer.msg("映票向上");
                change_status('votes','1');
            });

            //映票由高到低排序
            $(".votes_top .arrow-bottom").on('click',function(){
                //layer.msg("映票向下");
                change_status('votes','-1');
            });

            
            //总收益由低到高排序
            $(".votestotal_top .arrow-top").on('click',function(){
                //layer.msg("总收益向上");
                change_status('votestotal','1');
            });

            //总收益由高到低排序
            $(".votestotal_top .arrow-bottom").on('click',function(){
                //layer.msg("总收益向下");
                change_status('votestotal','-1');
            });

            //注册时间正序排序
            $(".createtime_top .arrow-top").on('click',function(){
                //layer.msg("正序");
                change_status('createtime','1');
            });

            //注册时间倒序排序
            $(".createtime_top .arrow-bottom").on('click',function(){
                //layer.msg("倒序");
                change_status('createtime','-1');
            });
        })

        function change_status(current,val){
            $("input[name='"+current+"_status']").val(val);
            var arr=['coin','consumption','votes','votestotal','createtime'];
            for (var i = 0; i < arr.length; i++) {
                if(arr[i]!=current){
                    $("input[name='"+arr[i]+"_status']").val('');
                }
            }

            $("form[name='search']").submit();
        }
    </script>
</body>
</html>